export function serverUrl() {
    // return 'http://java.3ddcim.com/v1'

    if (process.env.NODE_ENV === 'development') {
        console.log('现在是开发模式');
        return '/api'
    } else {
        console.log('现在不是开发模式');
        return '/v1'
    }
    
    
}

export async function request({ url, method = 'GET', data }) {
    return fetch(
        `${serverUrl()}${url}`,
        {
            method: method,
            headers: {
                "Content-Type": "application/json",
            },
            body: JSON.stringify(data),
        }
    )
}

export async function requestJSON({ url, method = 'GET', data }) {
    return (await request({ url, method, data })).json()
}
